<?php
/**
 *
 * 酒店搜索
 * @author liuw2
 *
 */
class get_OTA_IntlFlightSearch{
    /**
     * @var行程类型，必须填写  (单程 OW 默认 往返 RT 多程 MT)
     */
    var $TripType="";
    /**
     * @var乘客类型 (成人 ADT 默认、婴儿 INF、儿童 CHD) ，必须填写 
     */
    var $PassengerType="ADT";
    /**
     * @var乘客数量 ，必须填写
     */
    var $PassengerCount=1;
    /**
     *@var 舱位等级 ，必须填写   默认:Y(查询全部)  经济舱 Y 、超经舱 S 、公务舱 C  、头等舱 F 
     */
    var $ClassGrade="Y";   
    /**
     *@var 销售渠道 默认:网上销售  必须填写
     */
    var $SalesType="Online";    
    
    /**
     *@var 运价类型 默认:所有  必须填写
     */
    var $FareType="All";      
    
    /**
     *@var 结果模式  默认:所有价格   必须填写
     */
    var $ResultMode="All";   
    /**
     *@var 排序字段 默认:价格     必须填写
     */
    var $OrderBy="Price";    
    /**
     *@var 排序方向  默认:从低到高  必须填写
     */
    var $Direction="Asc";   
    
    /**
     *@var 出发城市码 必须填写
     */
    var $DCode="";   
    
    /**
     *@var 到达城市码 必须填写
     */
    var $ACode="";   
    
    /**
     *@var 出发日期
     */
    var $DDate="";   
    
    /**
     *@var返回体
     */
    var $ResponseXML="";

	/**
	 * 构造请求体
	 */
	private  function getRequestXML()
	{
		/*
		 * 从config.php中获取系统的联盟信息(只读)
		 */
		$AllianceID=Allianceid;
		$SID=Sid;
		$KEYS=SiteKey;
		$RequestType="OTA_IntlFlightSearch";
		//构造权限头部
		$headerRight=getRightString($AllianceID,$SID,$KEYS,$RequestType);
		$TripTypes="";
        if($this->TripType!=""){
            $TripTypes=<<<BEGIN
<TripType>$this->TripType</TripType>
BEGIN;
        }
        
        $PassengerTypes="";
        if($this->PassengerType!=""){
            $PassengerTypes=<<<BEGIN
            <PassengerType>$this->PassengerType</PassengerType>
BEGIN;
        }
        $PassengerCounts="";
        if($this->PassengerCount!=""){
            $PassengerCounts=<<<BEGIN
            <PassengerCount>$this->PassengerCount</PassengerCount>
BEGIN;
        }
        
        $ClassGrades="";
        if($this->ClassGrade!=""){
            $ClassGrades=<<<BEGIN
            <ClassGrade>$this->ClassGrade</ClassGrade>
BEGIN;
        }
        
        $FareTypes="";
        if($this->FareType!=""){
            $FareTypes=<<<BEGIN
            <FareType>$this->FareType</FareType>
BEGIN;
        }
        
        $ResultModes="";
        if($this->ResultMode!=""){
            $ResultModes=<<<BEGIN
            <ResultMode>$this->ResultMode</ResultMode>
BEGIN;
        }
        
        $OrderBys="";
        if($this->OrderBy!=""){
            $OrderBys=<<<BEGIN
            <OrderBy>$this->OrderBy</OrderBy>
BEGIN;
        }
                 
        $Directions="";
        if($this->Direction!=""){
            $Directions=<<<BEGIN
            <Direction>$this->Direction</Direction>
BEGIN;
        }
        $DCodes="";
        if($this->DCode!=""){
            $DCodes=<<<BEGIN
            <DCode>$this->DCode</DCode>
BEGIN;
        }
        $ACodes="";
        if($this->ACode!=""){
            $ACodes=<<<BEGIN
            <ACode>$this->ACode</ACode>
BEGIN;
        }
        $DDates="";
        if($this->DDate!=""){
            $DDates=<<<BEGIN
            <DDate>$this->DDate</DDate>
BEGIN;
        }
        
		
		$paravalues=<<<BEGIN
<?xml version="1.0" encoding="utf-8"?>
<Request> 
<Header $headerRight/>     
<IntlFlightSearchRequest>$TripTypes$PassengerTypes$PassengerCounts$ClassGrades$FareTypes$ResultModes$OrderBys$Directions<SegmentInfos><SegmentInfo>$DCodes$ACodes$DDates<TimePeriod>All</TimePeriod></SegmentInfo></SegmentInfos></IntlFlightSearchRequest>
</Request>
BEGIN;
		return  $paravalues;
	}

	/**
	 *
	 * 调用接口
	 */
	function main(){
		try{
			$requestXML=$this->getRequestXML();
			$commonRequestDo=new commonRequest();//常用数据请求
		 	$commonRequestDo->requestURL=OTA_IntlFlightSearch_Url;
		 	$commonRequestDo->requestXML=$requestXML;
		 	$commonRequestDo->requestType=System_RequestType;//取config中的配置
		 	$commonRequestDo->doRequest();
	 		$this->ResponseXML=getXMLFromReturnString($commonRequestDo->responseXML); 
		}
		catch(Exception $e)
		{
			$this->ResponseXML=null;
		}
	}
}
 